home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / kr_pat_parse.c < prev    next >
C/C++ Source or Header  |  1994-04-25  |  31KB  |  1,222 lines

  1.  
  2. /*  A Bison parser, made from kr_pat_parse.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define yyparse ppparse
  8. #define yylex pplex
  9. #define yyerror pperror
  10. #define yylval pplval
  11. #define yychar ppchar
  12. #define yydebug ppdebug
  13. #define yynerrs ppnerrs
  14. #define    L_BRACKET    258
  15. #define    R_BRACKET    259
  16. #define    VERSION_HEADER    260
  17. #define    GENERATED_AT    261
  18. #define    NO_OF_PATTERN    262
  19. #define    NO_OF_INPUT    263
  20. #define    NO_OF_OUTPUT    264
  21. #define    NO_OF_VAR_IDIM    265
  22. #define    NO_OF_VAR_ODIM    266
  23. #define    MAXIMUM_IDIM    267
  24. #define    MAXIMUM_ODIM    268
  25. #define    ERROR    269
  26. #define    PATTERNEND    270
  27. #define    NUMBER    271
  28. #define    V_NUMBER    272
  29.  
  30. #line 20 "kr_pat_parse.y"
  31.  
  32. #include <stdio.h>
  33.  
  34. /* since the generated parser needs alloca we need to do some special things */
  35. /* for some architectures: */
  36.  
  37. #ifndef alloca
  38. #ifndef __GNUC__
  39.  
  40. #ifdef __hpux
  41. #include <malloc.h>
  42. #include <stdio.h>
  43. #endif /* __hpux */
  44.  
  45. #ifdef sparc
  46. #include <alloca.h>
  47. #endif /* sparc */
  48.  
  49. #endif /* GNU C. not defined  */
  50. #endif /* alloca not defined.  */
  51.  
  52. #include "kr_typ.h"
  53. #include "glob_typ.h"
  54. #include "kernel.h"
  55. #include "kr_pat_scan.h"
  56. #include "kr_newpattern.h"
  57. #include "kr_pat_parse.ph"
  58.  
  59. #line 49 "kr_pat_parse.y"
  60. typedef union
  61. {
  62.     float    value;        /* allgemeine Zahl */    
  63.     struct
  64.     {
  65.         int    v;
  66.         int    r;
  67.     }    version;    /* Versionsnummer #.# */
  68. } YYSTYPE;
  69.  
  70. #ifndef YYLTYPE
  71. typedef
  72.   struct yyltype
  73.     {
  74.       int timestamp;
  75.       int first_line;
  76.       int first_column;
  77.       int last_line;
  78.       int last_column;
  79.       char *text;
  80.    }
  81.   yyltype;
  82.  
  83. #define YYLTYPE yyltype
  84. #endif
  85.  
  86. #include <stdio.h>
  87.  
  88. #ifndef __cplusplus
  89. #ifndef __STDC__
  90. #define const
  91. #endif
  92. #endif
  93.  
  94.  
  95.  
  96. #define    YYFINAL        49
  97. #define    YYFLAG        -32768
  98. #define    YYNTBASE    18
  99.  
  100. #define YYTRANSLATE(x) ((unsigned)(x) <= 272 ? yytranslate[x] : 39)
  101.  
  102. static const char yytranslate[] = {     0,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  118.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  119.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  120.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  122.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  123.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  124.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  125.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  126.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  127.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  128.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  129.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  130.     16,    17
  131. };
  132.  
  133. #if YYDEBUG != 0
  134. static const short yyprhs[] = {     0,
  135.      0,     1,     5,     6,     7,    19,    22,    25,    26,    31,
  136.     32,    37,    38,    39,    44,    47,    49,    52,    54,    56,
  137.     59,    60,    61,    62,    69,    71,    72,    74,    77
  138. };
  139.  
  140. static const short yyrhs[] = {    -1,
  141.     20,    19,    31,     0,     0,     0,     5,    17,    21,     6,
  142.      7,    16,    22,    23,    24,    25,    26,     0,     8,    16,
  143.      0,     9,    16,     0,     0,    10,    16,    12,    27,     0,
  144.      0,    11,    16,    13,    27,     0,     0,     0,     3,    28,
  145.     29,     4,     0,     3,     4,     0,    30,     0,    29,    30,
  146.      0,    16,     0,    32,     0,    31,    32,     0,     0,     0,
  147.      0,    33,    36,    34,    37,    35,    15,     0,    27,     0,
  148.      0,    38,     0,    37,    38,     0,    16,     0
  149. };
  150.  
  151. #endif
  152.  
  153. #if YYDEBUG != 0
  154. static const short yyrline[] = { 0,
  155.     72,    85,    95,   104,   113,   116,   127,   136,   140,   157,
  156.    161,   179,   183,   187,   188,   194,   195,   198,   215,   216,
  157.    219,   228,   293,   307,   309,   310,   317,   318,   321
  158. };
  159.  
  160. static const char * const yytname[] = {   "$","error","$illegal.","L_BRACKET",
  161. "R_BRACKET","VERSION_HEADER","GENERATED_AT","NO_OF_PATTERN","NO_OF_INPUT","NO_OF_OUTPUT",
  162. "NO_OF_VAR_IDIM","NO_OF_VAR_ODIM","MAXIMUM_IDIM","MAXIMUM_ODIM","ERROR","PATTERNEND",
  163. "NUMBER","V_NUMBER","pattern_file","@1","header","@2","@3","i_head","o_head",
  164. "vi_head","vo_head","actual_dim","@4","actual_dim_rest","dim_entry","pattern_list",
  165. "pattern","@5","@6","@7","pattern_start","pattern_body","pattern_entry",""
  166. };
  167. #endif
  168.  
  169. static const short yyr1[] = {     0,
  170.     19,    18,    21,    22,    20,    23,    24,    24,    25,    25,
  171.     26,    26,    28,    27,    27,    29,    29,    30,    31,    31,
  172.     33,    34,    35,    32,    36,    36,    37,    37,    38
  173. };
  174.  
  175. static const short yyr2[] = {     0,
  176.      0,     3,     0,     0,    11,     2,     2,     0,     4,     0,
  177.      4,     0,     0,     4,     2,     1,     2,     1,     1,     2,
  178.      0,     0,     0,     6,     1,     0,     1,     2,     1
  179. };
  180.  
  181. static const short yydefact[] = {     0,
  182.      0,     1,     3,    21,     0,    21,    19,    26,     0,    20,
  183.     13,    25,    22,     0,    15,     0,     0,     4,    18,     0,
  184.     16,    29,    23,    27,     0,    14,    17,     0,    28,     0,
  185.      8,    24,     6,     0,    10,     7,     0,    12,     0,     0,
  186.      5,     0,     0,     9,     0,    11,     0,     0,     0
  187. };
  188.  
  189. static const short yydefgoto[] = {    47,
  190.      4,     2,     5,    25,    31,    35,    38,    41,    12,    16,
  191.     20,    21,     6,     7,     8,    17,    28,    13,    23,    24
  192. };
  193.  
  194. static const short yypact[] = {    -3,
  195.    -14,-32768,-32768,-32768,    -1,     6,-32768,     4,     1,-32768,
  196.      5,-32768,-32768,    -6,-32768,    -5,    -2,-32768,-32768,    -4,
  197. -32768,-32768,    -2,-32768,     7,-32768,-32768,     2,-32768,     0,
  198.      9,-32768,-32768,     3,    10,-32768,     8,    11,    13,    12,
  199. -32768,     4,    14,-32768,     4,-32768,    21,    23,-32768
  200. };
  201.  
  202. static const short yypgoto[] = {-32768,
  203. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -41,-32768,
  204. -32768,    -7,-32768,    20,-32768,-32768,-32768,-32768,-32768,    15
  205. };
  206.  
  207.  
  208. #define    YYLAST        38
  209.  
  210.  
  211. static const short yytable[] = {    26,
  212.     44,     1,     3,    46,     9,    -2,    11,    14,    15,    18,
  213.     19,    19,    27,    22,    30,    33,    32,    34,    36,    37,
  214.     48,    40,    49,    39,    42,    10,    45,    43,     0,     0,
  215.      0,     0,     0,     0,     0,     0,     0,    29
  216. };
  217.  
  218. static const short yycheck[] = {     4,
  219.     42,     5,    17,    45,     6,     0,     3,     7,     4,    16,
  220.     16,    16,    20,    16,     8,    16,    15,     9,    16,    10,
  221.      0,    11,     0,    16,    12,     6,    13,    16,    -1,    -1,
  222.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    23
  223. };
  224. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  225. #line 3 "/usr/local/gnu/lib/bison-1.22/bison.simple"
  226.  
  227. /* Skeleton output parser for bison,
  228.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  229.  
  230.    This program is free software; you can redistribute it and/or modify
  231.    it under the terms of the GNU General Public License as published by
  232.    the Free Software Foundation; either version 1, or (at your option)
  233.    any later version.
  234.  
  235.    This program is distributed in the hope that it will be useful,
  236.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  237.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  238.    GNU General Public License for more details.
  239.  
  240.    You should have received a copy of the GNU General Public License
  241.    along with this program; if not, write to the Free Software
  242.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  243.  
  244.  
  245. #ifndef alloca
  246. #ifdef __GNUC__
  247. #define alloca __builtin_alloca
  248. #else /* not GNU C.  */
  249. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  250. #include <alloca.h>
  251. #else /* not sparc */
  252. #if defined (MSDOS) && !defined (__TURBOC__)
  253. #include <malloc.h>
  254. #else /* not MSDOS, or __TURBOC__ */
  255. #if defined(_AIX)
  256. #include <malloc.h>
  257.  #pragma alloca
  258. #else /* not MSDOS, __TURBOC__, or _AIX */
  259. #ifdef __hpux
  260. #ifdef __cplusplus
  261. extern "C" {
  262. void *alloca (unsigned int);
  263. };
  264. #else /* not __cplusplus */
  265. void *alloca ();
  266. #endif /* not __cplusplus */
  267. #endif /* __hpux */
  268. #endif /* not _AIX */
  269. #endif /* not MSDOS, or __TURBOC__ */
  270. #endif /* not sparc.  */
  271. #endif /* not GNU C.  */
  272. #endif /* alloca not defined.  */
  273.  
  274. /* This is the parser code that is written into each bison parser
  275.   when the %semantic_parser declaration is not specified in the grammar.
  276.   It was written by Richard Stallman by simplifying the hairy parser
  277.   used when %semantic_parser is specified.  */
  278.  
  279. /* Note: there must be only one dollar sign in this file.
  280.    It is replaced by the list of actions, each action
  281.    as one case of the switch.  */
  282.  
  283. #define yyerrok        (yyerrstatus = 0)
  284. #define yyclearin    (yychar = YYEMPTY)
  285. #define YYEMPTY        -2
  286. #define YYEOF        0
  287. #define YYACCEPT    return(0)
  288. #define YYABORT     return(1)
  289. #define YYERROR        goto yyerrlab1
  290. /* Like YYERROR except do call yyerror.
  291.    This remains here temporarily to ease the
  292.    transition to the new meaning of YYERROR, for GCC.
  293.    Once GCC version 2 has supplanted version 1, this can go.  */
  294. #define YYFAIL        goto yyerrlab
  295. #define YYRECOVERING()  (!!yyerrstatus)
  296. #define YYBACKUP(token, value) \
  297. do                                \
  298.   if (yychar == YYEMPTY && yylen == 1)                \
  299.     { yychar = (token), yylval = (value);            \
  300.       yychar1 = YYTRANSLATE (yychar);                \
  301.       YYPOPSTACK;                        \
  302.       goto yybackup;                        \
  303.     }                                \
  304.   else                                \
  305.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  306. while (0)
  307.  
  308. #define YYTERROR    1
  309. #define YYERRCODE    256
  310.  
  311. #ifndef YYPURE
  312. #define YYLEX        yylex()
  313. #endif
  314.  
  315. #ifdef YYPURE
  316. #ifdef YYLSP_NEEDED
  317. #define YYLEX        yylex(&yylval, &yylloc)
  318. #else
  319. #define YYLEX        yylex(&yylval)
  320. #endif
  321. #endif
  322.  
  323. /* If nonreentrant, generate the variables here */
  324.  
  325. #ifndef YYPURE
  326.  
  327. int    yychar;            /*  the lookahead symbol        */
  328. YYSTYPE    yylval;            /*  the semantic value of the        */
  329.                 /*  lookahead symbol            */
  330.  
  331. #ifdef YYLSP_NEEDED
  332. YYLTYPE yylloc;            /*  location data for the lookahead    */
  333.                 /*  symbol                */
  334. #endif
  335.  
  336. int yynerrs;            /*  number of parse errors so far       */
  337. #endif  /* not YYPURE */
  338.  
  339. #if YYDEBUG != 0
  340. int yydebug;            /*  nonzero means print parse trace    */
  341. /* Since this is uninitialized, it does not stop multiple parsers
  342.    from coexisting.  */
  343. #endif
  344.  
  345. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  346.  
  347. #ifndef    YYINITDEPTH
  348. #define YYINITDEPTH 200
  349. #endif
  350.  
  351. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  352.     (effective only if the built-in stack extension method is used).  */
  353.  
  354. #if YYMAXDEPTH == 0
  355. #undef YYMAXDEPTH
  356. #endif
  357.  
  358. #ifndef YYMAXDEPTH
  359. #define YYMAXDEPTH 10000
  360. #endif
  361.  
  362. /* Prevent warning if -Wstrict-prototypes.  */
  363. #ifdef __GNUC__
  364. int yyparse (void);
  365. #endif
  366.  
  367. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  368. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  369. #else                /* not GNU C or C++ */
  370. #ifndef __cplusplus
  371.  
  372. /* This is the most reliable way to avoid incompatibilities
  373.    in available built-in functions on various systems.  */
  374. static void
  375. __yy_bcopy (from, to, count)
  376.      char *from;
  377.      char *to;
  378.      int count;
  379. {
  380.   register char *f = from;
  381.   register char *t = to;
  382.   register int i = count;
  383.  
  384.   while (i-- > 0)
  385.     *t++ = *f++;
  386. }
  387.  
  388. #else /* __cplusplus */
  389.  
  390. /* This is the most reliable way to avoid incompatibilities
  391.    in available built-in functions on various systems.  */
  392. static void
  393. __yy_bcopy (char *from, char *to, int count)
  394. {
  395.   register char *f = from;
  396.   register char *t = to;
  397.   register int i = count;
  398.  
  399.   while (i-- > 0)
  400.     *t++ = *f++;
  401. }
  402.  
  403. #endif
  404. #endif
  405.  
  406. #line 184 "/usr/local/gnu/lib/bison-1.22/bison.simple"
  407. int
  408. yyparse()
  409. {
  410.   register int yystate;
  411.   register int yyn;
  412.   register short *yyssp;
  413.   register YYSTYPE *yyvsp;
  414.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  415.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  416.  
  417.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  418.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  419.  
  420.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  421.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  422.  
  423. #ifdef YYLSP_NEEDED
  424.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  425.   YYLTYPE *yyls = yylsa;
  426.   YYLTYPE *yylsp;
  427.  
  428. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  429. #else
  430. #define YYPOPSTACK   (yyvsp--, yyssp--)
  431. #endif
  432.  
  433.   int yystacksize = YYINITDEPTH;
  434.  
  435. #ifdef YYPURE
  436.   int yychar;
  437.   YYSTYPE yylval;
  438.   int yynerrs;
  439. #ifdef YYLSP_NEEDED
  440.   YYLTYPE yylloc;
  441. #endif
  442. #endif
  443.  
  444.   YYSTYPE yyval;        /*  the variable used to return        */
  445.                 /*  semantic values from the action    */
  446.                 /*  routines                */
  447.  
  448.   int yylen;
  449.  
  450. #if YYDEBUG != 0
  451.   if (yydebug)
  452.     fprintf(stderr, "Starting parse\n");
  453. #endif
  454.  
  455.   yystate = 0;
  456.   yyerrstatus = 0;
  457.   yynerrs = 0;
  458.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  459.  
  460.   /* Initialize stack pointers.
  461.      Waste one element of value and location stack
  462.      so that they stay on the same level as the state stack.
  463.      The wasted elements are never initialized.  */
  464.  
  465.   yyssp = yyss - 1;
  466.   yyvsp = yyvs;
  467. #ifdef YYLSP_NEEDED
  468.   yylsp = yyls;
  469. #endif
  470.  
  471. /* Push a new state, which is found in  yystate  .  */
  472. /* In all cases, when you get here, the value and location stacks
  473.    have just been pushed. so pushing a state here evens the stacks.  */
  474. yynewstate:
  475.  
  476.   *++yyssp = yystate;
  477.  
  478.   if (yyssp >= yyss + yystacksize - 1)
  479.     {
  480.       /* Give user a chance to reallocate the stack */
  481.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  482.       YYSTYPE *yyvs1 = yyvs;
  483.       short *yyss1 = yyss;
  484. #ifdef YYLSP_NEEDED
  485.       YYLTYPE *yyls1 = yyls;
  486. #endif
  487.  
  488.       /* Get the current used size of the three stacks, in elements.  */
  489.       int size = yyssp - yyss + 1;
  490.  
  491. #ifdef yyoverflow
  492.       /* Each stack pointer address is followed by the size of
  493.      the data in use in that stack, in bytes.  */
  494. #ifdef YYLSP_NEEDED
  495.       /* This used to be a conditional around just the two extra args,
  496.      but that might be undefined if yyoverflow is a macro.  */
  497.       yyoverflow("parser stack overflow",
  498.          &yyss1, size * sizeof (*yyssp),
  499.          &yyvs1, size * sizeof (*yyvsp),
  500.          &yyls1, size * sizeof (*yylsp),
  501.          &yystacksize);
  502. #else
  503.       yyoverflow("parser stack overflow",
  504.          &yyss1, size * sizeof (*yyssp),
  505.          &yyvs1, size * sizeof (*yyvsp),
  506.          &yystacksize);
  507. #endif
  508.  
  509.       yyss = yyss1; yyvs = yyvs1;
  510. #ifdef YYLSP_NEEDED
  511.       yyls = yyls1;
  512. #endif
  513. #else /* no yyoverflow */
  514.       /* Extend the stack our own way.  */
  515.       if (yystacksize >= YYMAXDEPTH)
  516.     {
  517.       yyerror("parser stack overflow");
  518.       return 2;
  519.     }
  520.       yystacksize *= 2;
  521.       if (yystacksize > YYMAXDEPTH)
  522.     yystacksize = YYMAXDEPTH;
  523.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  524.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  525.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  526.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  527. #ifdef YYLSP_NEEDED
  528.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  529.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  530. #endif
  531. #endif /* no yyoverflow */
  532.  
  533.       yyssp = yyss + size - 1;
  534.       yyvsp = yyvs + size - 1;
  535. #ifdef YYLSP_NEEDED
  536.       yylsp = yyls + size - 1;
  537. #endif
  538.  
  539. #if YYDEBUG != 0
  540.       if (yydebug)
  541.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  542. #endif
  543.  
  544.       if (yyssp >= yyss + yystacksize - 1)
  545.     YYABORT;
  546.     }
  547.  
  548. #if YYDEBUG != 0
  549.   if (yydebug)
  550.     fprintf(stderr, "Entering state %d\n", yystate);
  551. #endif
  552.  
  553.   goto yybackup;
  554.  yybackup:
  555.  
  556. /* Do appropriate processing given the current state.  */
  557. /* Read a lookahead token if we need one and don't already have one.  */
  558. /* yyresume: */
  559.  
  560.   /* First try to decide what to do without reference to lookahead token.  */
  561.  
  562.   yyn = yypact[yystate];
  563.   if (yyn == YYFLAG)
  564.     goto yydefault;
  565.  
  566.   /* Not known => get a lookahead token if don't already have one.  */
  567.  
  568.   /* yychar is either YYEMPTY or YYEOF
  569.      or a valid token in external form.  */
  570.  
  571.   if (yychar == YYEMPTY)
  572.     {
  573. #if YYDEBUG != 0
  574.       if (yydebug)
  575.     fprintf(stderr, "Reading a token: ");
  576. #endif
  577.       yychar = YYLEX;
  578.     }
  579.  
  580.   /* Convert token to internal form (in yychar1) for indexing tables with */
  581.  
  582.   if (yychar <= 0)        /* This means end of input. */
  583.     {
  584.       yychar1 = 0;
  585.       yychar = YYEOF;        /* Don't call YYLEX any more */
  586.  
  587. #if YYDEBUG != 0
  588.       if (yydebug)
  589.     fprintf(stderr, "Now at end of input.\n");
  590. #endif
  591.     }
  592.   else
  593.     {
  594.       yychar1 = YYTRANSLATE(yychar);
  595.  
  596. #if YYDEBUG != 0
  597.       if (yydebug)
  598.     {
  599.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  600.       /* Give the individual parser a way to print the precise meaning
  601.          of a token, for further debugging info.  */
  602. #ifdef YYPRINT
  603.       YYPRINT (stderr, yychar, yylval);
  604. #endif
  605.       fprintf (stderr, ")\n");
  606.     }
  607. #endif
  608.     }
  609.  
  610.   yyn += yychar1;
  611.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  612.     goto yydefault;
  613.  
  614.   yyn = yytable[yyn];
  615.  
  616.   /* yyn is what to do for this token type in this state.
  617.      Negative => reduce, -yyn is rule number.
  618.      Positive => shift, yyn is new state.
  619.        New state is final state => don't bother to shift,
  620.        just return success.
  621.      0, or most negative number => error.  */
  622.  
  623.   if (yyn < 0)
  624.     {
  625.       if (yyn == YYFLAG)
  626.     goto yyerrlab;
  627.       yyn = -yyn;
  628.       goto yyreduce;
  629.     }
  630.   else if (yyn == 0)
  631.     goto yyerrlab;
  632.  
  633.   if (yyn == YYFINAL)
  634.     YYACCEPT;
  635.  
  636.   /* Shift the lookahead token.  */
  637.  
  638. #if YYDEBUG != 0
  639.   if (yydebug)
  640.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  641. #endif
  642.  
  643.   /* Discard the token being shifted unless it is eof.  */
  644.   if (yychar != YYEOF)
  645.     yychar = YYEMPTY;
  646.  
  647.   *++yyvsp = yylval;
  648. #ifdef YYLSP_NEEDED
  649.   *++yylsp = yylloc;
  650. #endif
  651.  
  652.   /* count tokens shifted since error; after three, turn off error status.  */
  653.   if (yyerrstatus) yyerrstatus--;
  654.  
  655.   yystate = yyn;
  656.   goto yynewstate;
  657.  
  658. /* Do the default action for the current state.  */
  659. yydefault:
  660.  
  661.   yyn = yydefact[yystate];
  662.   if (yyn == 0)
  663.     goto yyerrlab;
  664.  
  665. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  666. yyreduce:
  667.   yylen = yyr2[yyn];
  668.   if (yylen > 0)
  669.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  670.  
  671. #if YYDEBUG != 0
  672.   if (yydebug)
  673.     {
  674.       int i;
  675.  
  676.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  677.            yyn, yyrline[yyn]);
  678.  
  679.       /* Print the symbols being reduced, and their result.  */
  680.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  681.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  682.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  683.     }
  684. #endif
  685.  
  686.  
  687.   switch (yyn) {
  688.  
  689. case 1:
  690. #line 73 "kr_pat_parse.y"
  691. {    
  692.             current_pattern = 0;
  693.             next_pattern_is_input = 1;
  694.  
  695.             if (kr_np_AllocatePatternSet(&pattern_set, no_of_pattern)
  696.             != KRERR_NO_ERROR)
  697.             { 
  698.             yyerror("can't allocate memory"); 
  699.             YYABORT; 
  700.             }
  701.         ;
  702.     break;}
  703. case 2:
  704. #line 85 "kr_pat_parse.y"
  705. {
  706.             if (current_pattern < no_of_pattern ||
  707.             !next_pattern_is_input)
  708.             { 
  709.             yyerror("unexpected end of file"); 
  710.             YYABORT; 
  711.             }
  712.         ;
  713.     break;}
  714. case 3:
  715. #line 96 "kr_pat_parse.y"
  716. {
  717.         if ((yyvsp[0].version.v == CURRENT_VERSION_V && yyvsp[0].version.r > CURRENT_VERSION_R) ||
  718.             yyvsp[0].version.v > CURRENT_VERSION_V)
  719.         { 
  720.             yyerror("version of pattern file not supported"); 
  721.             YYABORT; 
  722.         }
  723.     ;
  724.     break;}
  725. case 4:
  726. #line 105 "kr_pat_parse.y"
  727. {
  728.         no_of_pattern = (int) yyvsp[0].value;
  729.         if (no_of_pattern <= 0)
  730.         { 
  731.             yyerror("illegal number of pattern"); 
  732.             YYABORT; 
  733.         }
  734.     ;
  735.     break;}
  736. case 6:
  737. #line 117 "kr_pat_parse.y"
  738.         no_of_input = (int) yyvsp[0].value;
  739.         if (no_of_input < 0)
  740.         { 
  741.             yyerror("illegal number of input units"); 
  742.             YYABORT; 
  743.         } 
  744.     ;
  745.     break;}
  746. case 7:
  747. #line 128 "kr_pat_parse.y"
  748.         no_of_output = (int) yyvsp[0].value;
  749.         if (no_of_output < 0)
  750.         { 
  751.             yyerror("illegal number of output units"); 
  752.             YYABORT; 
  753.         } 
  754.     ;
  755.     break;}
  756. case 8:
  757. #line 137 "kr_pat_parse.y"
  758. { no_of_output = 0; ;
  759.     break;}
  760. case 9:
  761. #line 141 "kr_pat_parse.y"
  762. {
  763.         variable_input_dim = yyvsp[-2].value; 
  764.         if (variable_input_dim < 0 || 
  765.             variable_input_dim > MAX_NO_OF_VAR_I_DIM)
  766.         { 
  767.             yyerror("illegal variable input dimensions"); 
  768.             YYABORT; 
  769.         }
  770.         if (actual_dim_count != variable_input_dim)
  771.         { 
  772.             yyerror("illegal number of entries in dimension list"); 
  773.             YYABORT; 
  774.         }
  775.         for (i=0; i<variable_input_dim; i++)
  776.             max_i_dims[i] = dims[i];
  777.     ;
  778.     break;}
  779. case 10:
  780. #line 158 "kr_pat_parse.y"
  781. { variable_input_dim = 0; ;
  782.     break;}
  783. case 11:
  784. #line 162 "kr_pat_parse.y"
  785. {
  786.         variable_output_dim = yyvsp[-2].value; 
  787.         if (variable_output_dim < 0 || 
  788.             variable_output_dim > MAX_NO_OF_VAR_O_DIM ||
  789.             no_of_output == 0)
  790.         { 
  791.             yyerror("illegal variable output dimensions"); 
  792.             YYABORT; 
  793.         }
  794.         if (actual_dim_count != variable_output_dim)
  795.         { 
  796.             yyerror("illegal number of entries in dimension list"); 
  797.             YYABORT; 
  798.         }
  799.         for (i=0; i<variable_output_dim; i++)
  800.             max_o_dims[i] = dims[i];    
  801.     ;
  802.     break;}
  803. case 12:
  804. #line 180 "kr_pat_parse.y"
  805. { variable_output_dim = 0; ;
  806.     break;}
  807. case 13:
  808. #line 184 "kr_pat_parse.y"
  809. {
  810.             actual_dim_count = 0;
  811.         ;
  812.     break;}
  813. case 15:
  814. #line 189 "kr_pat_parse.y"
  815. {
  816.                 actual_dim_count = 0;
  817.         ;
  818.     break;}
  819. case 18:
  820. #line 199 "kr_pat_parse.y"
  821. {
  822.         if (actual_dim_count >= MAX_NO_OF_VAR_DIM)
  823.         { 
  824.             yyerror("to many entries in dimension list"); 
  825.             YYABORT; 
  826.         }
  827.         dims[actual_dim_count] = (int) yyvsp[0].value;
  828.         if (dims[actual_dim_count] <= 0)
  829.         { 
  830.             yyerror("illegal size of dimension"); 
  831.             YYABORT; 
  832.         }
  833.         actual_dim_count++;
  834.     ;
  835.     break;}
  836. case 21:
  837. #line 220 "kr_pat_parse.y"
  838. {
  839.     if (current_pattern >= no_of_pattern)
  840.     { 
  841.     yyerror("to many patterns"); 
  842.     YYABORT; 
  843.     }
  844. ;
  845.     break;}
  846. case 22:
  847. #line 228 "kr_pat_parse.y"
  848. {
  849.     if (kr_np_GetDescriptor(pattern_set, current_pattern, &pattern)
  850.     != KRERR_NO_ERROR)
  851.     {
  852.     yyerror("pattern parser internal error");
  853.     YYABORT;
  854.     }
  855.     if (next_pattern_is_input)
  856.     {
  857.     pattern -> input_fixsize = no_of_input;
  858.     pattern -> input_dim = variable_input_dim;
  859.     pattern -> output_fixsize = no_of_output;
  860.     pattern -> output_dim = variable_output_dim;
  861.     if (actual_dim_count != variable_input_dim)
  862.     { 
  863.         yyerror("illegal number of entries in dimension list"); 
  864.         YYABORT; 
  865.     }
  866.     act_size = no_of_input;
  867.     for (i=0; i<variable_input_dim; i++)
  868.     {
  869.         if (dims[i] > max_i_dims[i])
  870.         { 
  871.         yyerror("variable dimension overflow"); 
  872.         YYABORT; 
  873.         }
  874.         act_size *= dims[i];
  875.         (pattern -> input_dim_sizes)[i] = dims[i];
  876.     }
  877.     if (kr_np_AllocatePattern(pattern, next_pattern_is_input)
  878.         != KRERR_NO_ERROR)
  879.     { 
  880.         yyerror("can't allocate memory"); 
  881.         YYABORT; 
  882.     }
  883.     pat_mem = pattern -> input_pattern;
  884.     }
  885.     else
  886.     {
  887.     if (actual_dim_count != variable_output_dim)
  888.     { 
  889.         yyerror("illegal number of entries in dimension list"); 
  890.         YYABORT; 
  891.     }
  892.     act_size = no_of_output;
  893.     for (i=0; i<variable_output_dim; i++)
  894.     {
  895.         if (dims[i] > max_o_dims[i])
  896.         { 
  897.         yyerror("variable dimension overflow"); 
  898.         YYABORT; 
  899.         }
  900.         act_size *= dims[i];
  901.         (pattern -> output_dim_sizes)[i] = dims[i];
  902.     }
  903.     if (kr_np_AllocatePattern(pattern, next_pattern_is_input)
  904.         != KRERR_NO_ERROR)
  905.     { 
  906.         yyerror("can't allocate memory"); 
  907.         YYABORT; 
  908.     }
  909.     pat_mem = pattern -> output_pattern;
  910.     }
  911. ;
  912.     break;}
  913. case 23:
  914. #line 293 "kr_pat_parse.y"
  915. {
  916.     if (act_size > 0)
  917.     { 
  918.     yyerror("to little values in pattern"); 
  919.     YYABORT; 
  920.     }
  921.     
  922.     if (no_of_output > 0)
  923.     next_pattern_is_input = !next_pattern_is_input;
  924.     
  925.     if (next_pattern_is_input)
  926.     current_pattern++;
  927. ;
  928.     break;}
  929. case 26:
  930. #line 311 "kr_pat_parse.y"
  931. {
  932.     actual_dim_count = 0;
  933. ;
  934.     break;}
  935. case 29:
  936. #line 322 "kr_pat_parse.y"
  937. {
  938.         if (act_size == 0)
  939.         { 
  940.             yyerror("to many values in pattern"); 
  941.             YYABORT; 
  942.         }
  943.         *pat_mem++ = yyvsp[0].value;
  944.         if (--act_size == 0)
  945.             scanner_await_pattern_end(); 
  946.     ;
  947.     break;}
  948. }
  949.    /* the action file gets copied in in place of this dollarsign */
  950. #line 465 "/usr/local/gnu/lib/bison-1.22/bison.simple"
  951.  
  952.   yyvsp -= yylen;
  953.   yyssp -= yylen;
  954. #ifdef YYLSP_NEEDED
  955.   yylsp -= yylen;
  956. #endif
  957.  
  958. #if YYDEBUG != 0
  959.   if (yydebug)
  960.     {
  961.       short *ssp1 = yyss - 1;
  962.       fprintf (stderr, "state stack now");
  963.       while (ssp1 != yyssp)
  964.     fprintf (stderr, " %d", *++ssp1);
  965.       fprintf (stderr, "\n");
  966.     }
  967. #endif
  968.  
  969.   *++yyvsp = yyval;
  970.  
  971. #ifdef YYLSP_NEEDED
  972.   yylsp++;
  973.   if (yylen == 0)
  974.     {
  975.       yylsp->first_line = yylloc.first_line;
  976.       yylsp->first_column = yylloc.first_column;
  977.       yylsp->last_line = (yylsp-1)->last_line;
  978.       yylsp->last_column = (yylsp-1)->last_column;
  979.       yylsp->text = 0;
  980.     }
  981.   else
  982.     {
  983.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  984.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  985.     }
  986. #endif
  987.  
  988.   /* Now "shift" the result of the reduction.
  989.      Determine what state that goes to,
  990.      based on the state we popped back to
  991.      and the rule number reduced by.  */
  992.  
  993.   yyn = yyr1[yyn];
  994.  
  995.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  996.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  997.     yystate = yytable[yystate];
  998.   else
  999.     yystate = yydefgoto[yyn - YYNTBASE];
  1000.  
  1001.   goto yynewstate;
  1002.  
  1003. yyerrlab:   /* here on detecting error */
  1004.  
  1005.   if (! yyerrstatus)
  1006.     /* If not already recovering from an error, report this error.  */
  1007.     {
  1008.       ++yynerrs;
  1009.  
  1010. #ifdef YYERROR_VERBOSE
  1011.       yyn = yypact[yystate];
  1012.  
  1013.       if (yyn > YYFLAG && yyn < YYLAST)
  1014.     {
  1015.       int size = 0;
  1016.       char *msg;
  1017.       int x, count;
  1018.  
  1019.       count = 0;
  1020.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1021.       for (x = (yyn < 0 ? -yyn : 0);
  1022.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1023.         if (yycheck[x + yyn] == x)
  1024.           size += strlen(yytname[x]) + 15, count++;
  1025.       msg = (char *) malloc(size + 15);
  1026.       if (msg != 0)
  1027.         {
  1028.           strcpy(msg, "parse error");
  1029.  
  1030.           if (count < 5)
  1031.         {
  1032.           count = 0;
  1033.           for (x = (yyn < 0 ? -yyn : 0);
  1034.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1035.             if (yycheck[x + yyn] == x)
  1036.               {
  1037.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1038.             strcat(msg, yytname[x]);
  1039.             strcat(msg, "'");
  1040.             count++;
  1041.               }
  1042.         }
  1043.           yyerror(msg);
  1044.           free(msg);
  1045.         }
  1046.       else
  1047.         yyerror ("parse error; also virtual memory exceeded");
  1048.     }
  1049.       else
  1050. #endif /* YYERROR_VERBOSE */
  1051.     yyerror("parse error");
  1052.     }
  1053.  
  1054.   goto yyerrlab1;
  1055. yyerrlab1:   /* here on error raised explicitly by an action */
  1056.  
  1057.   if (yyerrstatus == 3)
  1058.     {
  1059.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1060.  
  1061.       /* return failure if at end of input */
  1062.       if (yychar == YYEOF)
  1063.     YYABORT;
  1064.  
  1065. #if YYDEBUG != 0
  1066.       if (yydebug)
  1067.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1068. #endif
  1069.  
  1070.       yychar = YYEMPTY;
  1071.     }
  1072.  
  1073.   /* Else will try to reuse lookahead token
  1074.      after shifting the error token.  */
  1075.  
  1076.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1077.  
  1078.   goto yyerrhandle;
  1079.  
  1080. yyerrdefault:  /* current state does not do anything special for the error token. */
  1081.  
  1082. #if 0
  1083.   /* This is wrong; only states that explicitly want error tokens
  1084.      should shift them.  */
  1085.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1086.   if (yyn) goto yydefault;
  1087. #endif
  1088.  
  1089. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1090.  
  1091.   if (yyssp == yyss) YYABORT;
  1092.   yyvsp--;
  1093.   yystate = *--yyssp;
  1094. #ifdef YYLSP_NEEDED
  1095.   yylsp--;
  1096. #endif
  1097.  
  1098. #if YYDEBUG != 0
  1099.   if (yydebug)
  1100.     {
  1101.       short *ssp1 = yyss - 1;
  1102.       fprintf (stderr, "Error: state stack now");
  1103.       while (ssp1 != yyssp)
  1104.     fprintf (stderr, " %d", *++ssp1);
  1105.       fprintf (stderr, "\n");
  1106.     }
  1107. #endif
  1108.  
  1109. yyerrhandle:
  1110.  
  1111.   yyn = yypact[yystate];
  1112.   if (yyn == YYFLAG)
  1113.     goto yyerrdefault;
  1114.  
  1115.   yyn += YYTERROR;
  1116.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1117.     goto yyerrdefault;
  1118.  
  1119.   yyn = yytable[yyn];
  1120.   if (yyn < 0)
  1121.     {
  1122.       if (yyn == YYFLAG)
  1123.     goto yyerrpop;
  1124.       yyn = -yyn;
  1125.       goto yyreduce;
  1126.     }
  1127.   else if (yyn == 0)
  1128.     goto yyerrpop;
  1129.  
  1130.   if (yyn == YYFINAL)
  1131.     YYACCEPT;
  1132.  
  1133. #if YYDEBUG != 0
  1134.   if (yydebug)
  1135.     fprintf(stderr, "Shifting error token, ");
  1136. #endif
  1137.  
  1138.   *++yyvsp = yylval;
  1139. #ifdef YYLSP_NEEDED
  1140.   *++yylsp = yylloc;
  1141. #endif
  1142.  
  1143.   yystate = yyn;
  1144.   goto yynewstate;
  1145. }
  1146. #line 335 "kr_pat_parse.y"
  1147.  
  1148.  
  1149. #ifndef alloca
  1150. #ifndef __GNUC__
  1151. #ifdef __hpux
  1152. /*****************************************************************************
  1153.   FUNCTION : alloca
  1154.  
  1155.   PURPOSE  : must be provided for the parser.
  1156.              Uses malloc to allocate memory. This memory is not automatically
  1157.              freed as in the original alloca definition 
  1158.   RETURNS  : pointer to memory
  1159.   NOTES    : This is necessary for HP_UX only since there comes no alloca() 
  1160.              with the HP cc C-compiler.
  1161.          It is not necessary with Gnu C
  1162.  
  1163.   UPDATE   : 
  1164. ******************************************************************************/
  1165. void *alloca(int size)
  1166. {
  1167.     void *p;
  1168.  
  1169.     p = malloc(size);
  1170.     fprintf(stderr, "warning: malloc called instead of alloca\n");
  1171.     return p;
  1172. }
  1173. #endif /* __hpux */
  1174. #endif /* GNU C. not defined  */
  1175. #endif /* alloca not defined.  */
  1176.  
  1177. /*****************************************************************************
  1178.   FUNCTION : yyerror
  1179.  
  1180.   PURPOSE  : must be provided for the parser.
  1181.              reports errors in pattern file to stderr
  1182.   RETURNS  : nothing
  1183.   NOTES    :
  1184.  
  1185.   UPDATE   : 
  1186. ******************************************************************************/
  1187. static void yyerror(char *error)
  1188. {
  1189.     fprintf(stderr, "Parse error in pattern file at line %d:\n%s\n",
  1190.         lineno, error);
  1191. }
  1192.  
  1193. /*****************************************************************************
  1194.   FUNCTION : parse_pattern_file
  1195.  
  1196.   PURPOSE  : calls the real parser
  1197.  
  1198.   RETURNS  : parser error code and the handle to the loaded pattern set
  1199.   NOTES    :
  1200.  
  1201.   UPDATE   : 
  1202. ******************************************************************************/
  1203. int parse_pattern_file(int *set)
  1204. {
  1205.     int err;
  1206.  
  1207.     lineno = 1;
  1208.     err = yyparse();
  1209.     *set = pattern_set;
  1210.  
  1211.     if (err == 0)
  1212.     lineno = 0;
  1213.  
  1214.     return err;
  1215. }
  1216.  
  1217. /*****************************************************************************
  1218. END OF FILE
  1219. ******************************************************************************/
  1220.